package cn.edu.scau.cmi.ema.util;

import com.huaban.analysis.jieba.JiebaSegmenter;
import com.huaban.analysis.jieba.JiebaSegmenter.SegMode;
import com.huaban.analysis.jieba.SegToken;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class SegmenterUtil {
	public static Set<String> getSegmentByIndex(String sentence){
		Set<String> segments = new HashSet<String>();
		JiebaSegmenter segmenter = new JiebaSegmenter();
		List<SegToken> segTokens = segmenter.process(sentence, SegMode.INDEX);
		for(SegToken segTolen : segTokens) {
			segments.add(segTolen.word);
		}
		return segments;
	}


	public static Set<String> getSegmentBySearch(String sentence){
		Set<String> segments = new HashSet<String>();
		JiebaSegmenter segmenter = new JiebaSegmenter();
		List<SegToken> segTokens = segmenter.process(sentence, SegMode.SEARCH);
		for(SegToken segTolen : segTokens) {
			segments.add(segTolen.word);
		}
		return segments;
	}



}
